<template>
  <div>
    <div class="his-hot" v-show="isShowHistory">
      <div class="hd">
        <h4>历史记录</h4>
        <van-icon name="delete-o" @click="clearHistory"  />
      </div>
      <div class="bd" >
      <van-tag @click="tagClick(item)" v-for="(item,index) in searchHistoryData" :key="index"   plain :type="item.is_hot?'danger':'default'">{{item}}</van-tag>
      </div>
    </div>

    <div class="his-hot">
      <div class="hd">
        <h4>热门记录</h4>
      </div>
      <div class="bd">
        <!-- 父传子三部曲 第三步 -->
      <van-tag @click="tagClick(item.keyword)" v-for="(item,index) in searchHotData" :key="index"   plain :type="item.is_hot?'danger':'default'">{{item.keyword}}</van-tag>
      </div>
    </div>
  </div>
</template>

<script>
import {ClearHistory} from '../request/api'
export default {
  data() {
    return {
      isShowHistory:true
    };
  },
  // 父传子三部曲 第二部
  props:['searchHistoryData','searchHotData'],
  methods:{
    tagClick(val){
      this.$emit('tagClick',val)
    },
    clearHistory(){
      ClearHistory().then(res =>{
        this.$toast('删除成功');
        setTimeout(
          this.isShowHistory = false
          ,1000)
      })
    }
  }
};
</script>
 
<style lang = "less" scoped>
.his-hot {
  background-color: #fff;
  padding: 0.1rem;
margin-bottom: 0.2rem;
  .hd {
    display: flex;
    justify-content: space-between;
    font-size: 0.2rem;
    margin-bottom: .1rem;
    h4 {
      font-size: 0.22rem;
    }
  }

  .van-tag{
      margin-right: .08rem;
      padding: .03rem;
      margin-top: .08rem;
  }
}
</style>